<template>
  <div class="fetch-demo">
    <h1>fetch-demo</h1>
    <div>
      <div v-for="item in categoriesList" :key="item.id">
        {{ item.name }}
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';

import { categories } from '../api/api';

const categoriesList = ref([])
const getCategories = () => {
  const params = {}
  categories(params).then(res => {
    console.log("getCategories", res)
    categoriesList.value = res
  })
}
onMounted(() => {
  console.log('fetch-demo')
  getCategories()
});

</script>

<style scoped>
/* 样式内容 */
</style>